<template>
	<view :class="{
		'wx-dialog_mask':true,
		'active_bottom':direction=='bottom',
		'active_center':direction=='center'}"
	 	v-if="showDialog"
		 @click.stop="hideDialog"
	>
		<view :class="{'wx-dialog_wrapper':true,'wx-dialog_show':showDialog,'wx-dialog_hide':!showDialog}" @click.stop>
			<slot name="dialogContent"></slot>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'wxDialog',
		props: {
			showDialog: {
				type: Boolean,
				default: false
			},
			direction: {
				type: String,
				default: 'bottom'
			}
		},
		methods:{
			hideDialog(){
				this.$emit('onHideDialog')
			}
		}
	}
</script>

<style lang="scss" scoped>
	@keyframes dialogshow{
		0%{
			transform:translateY(50%);
		}
		100%{
			transform:translateY(0%);
		}
	}
	
	.wx-dialog_mask {
		position: fixed;
		top: 0;
		left: 0;
		z-index:999;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.6);
		.wx-dialog_wrapper {
			width: 100%;
		}
		.wx-dialog_show{
			animation: dialogshow .5s;
		}
	}

	.active_bottom {
		display: flex;
		flex-direction: column-reverse;
	}
	.active_center{
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>
